﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Threading.Tasks;

namespace DataConnector
{
    public sealed class SerialConnectorLayer
    {
        #region Singleton

        private static readonly SerialConnectorLayer instance = new SerialConnectorLayer();

        static SerialConnectorLayer()
        { }

        private SerialConnectorLayer()
        {

        }

        public static SerialConnectorLayer Instance
        {
            get
            {
                return instance;
            }
        }

        #endregion

        #region API

        public string GetNextBarcode()
        {
            int nextBarcode = 1;
            var lastProduct = DataConnectorLayer.Instance.R_ProductObject.FindAll().OrderByDescending(x => x.ProductObjectID).FirstOrDefault();

            if (lastProduct != null)
            {
                nextBarcode = int.Parse(lastProduct.ProductObjectID.ToString()) + 1;
            }

            return (nextBarcode).ToString("0 00 00000 00000 0");
        }

        #endregion

        #region Helper



        #endregion
    }
}